unit Mathematic;

interface

uses Math, SysUtils;

type
    TFloat = Double;
    TFloatPointer = ^Double;
var Debug: Boolean;
const
    MinFloat = MinDouble;
    MaxFloat = MaxDouble;
    Pi = 3.14159265358979323846      +               // Pi
         0.26433832795028841971e-20  +
         0.69399375105820974944e-40  +
         0.59230781640628620899e-60  +
         0.86280348253421170679e-80  +
         0.82148086513282306647e-100 +
         0.09384460955058223172e-120 +
         0.53594081284811174502e-140 +
         0.84102701938521105559e-160 +
         0.64462294895493038196e-180;
    SqrPi = 9.869604401089358618834490999876151;     // Sqr(Pi)
    SqrtPi = 1.772453850905516027298167483341145;    // Sqrt(Pi)
    RadPerDeg = 0.017453292519943295769236907684886; // Pi / 180
    DegPerRad = 57.29577951308232087679815481410517; // 180 / Pi

function RadToDeg(paRadians: TFloat): TFloat;
function DegToRad(paDegrees: TFloat): TFloat;
function FloatToFile(paFloat: TFloat; var F: Text): Boolean;
function FloatFromFile(var paFloat: TFloat; var F: Text): Boolean;
function IntegerToFile(paInteger: Integer; var F: Text): Boolean;
function IntegerFromFile(var paInteger: Integer; var F: Text): Boolean;

implementation

function RadToDeg(paRadians: TFloat): TFloat;
begin
    Result := paRadians * DegPerRad;
end;

function DegToRad(paDegrees: TFloat): TFloat;
begin
    Result := paDegrees * RadPerDeg;
end;

function FloatToFile(paFloat: TFloat; var F: Text): Boolean;
begin
    System.Writeln(F, paFloat);
end;

function FloatFromFile(var paFloat: TFloat; var F: Text): Boolean;
var Line: String;
begin
    System.Readln(F, Line);
    paFloat := StrToFloat(Line);
end;

function IntegerToFile(paInteger: Integer; var F: Text): Boolean;
begin
    System.Writeln(F, paInteger);
end;

function IntegerFromFile(var paInteger: Integer; var F: Text): Boolean;
var Line: String;
begin
    System.Readln(F, Line);
    paInteger := StrToInt(Line);
end;

end.
